local skel = fk.CreateSkill {
  name = "lb__juju",
}

Fk:loadTranslationTable {
  ["lb__juju"] = "踽踽",
  [":lb__juju"] = "你可以将一个区域内的最后一张牌当【杀】使用；你击杀角色后不执行身份奖惩且【杀】的使用次数上限+1。",

  ["#lb__juju_skip"] = "踽踽",
  ["#lb__juju"] = "踽踽：你可以将一个区域内的最后一张牌当【杀】使用",

  ["$lb__juju1"] = "切勿回头，来处无路可走。",
  ["$lb__juju2"] = "又一场雨…一场空白…",
}

skel:addEffect("viewas", {
  anim_type = "offensive",
  pattern = "slash",
  prompt = "#lb__juju",
  interaction = function(self, player)
    local all = { "$Hand", "$Equip", "$Judge" }
    local ask = {}
    for i, s in ipairs({ "h", "e", "j" }) do
      if #player:getCardIds(s) == 1 then
        table.insert(ask, all[i])
      end
    end
    return UI.ComboBox {
      choices = ask,
      all_choices = all,
    }
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    if self.interaction.data == nil then return end
    local all = { "h", "e", "j" }
    local ids
    for i, s in ipairs({ "$Hand", "$Equip", "$Judge" }) do
      if self.interaction.data == s then
        ids = player:getCardIds(all[i])
        if #ids ~= 1 then return end
      end
    end
    local c = Fk:cloneCard("slash")
    c.skillName = skel.name
    local card = Fk:getCardById(ids[1])
    if card.sub_type == Card.SubtypeWeapon and card.name == player:getMark("lb__huaiwu") then --单独解决飞刀吧
      Fk:currentRoom():setBanner(skel.name .. player.id, card.id)
    else
      c:addSubcards(ids)
    end
    return c
  end,
  before_use = function(self, player, use)
    local id = Fk:currentRoom():getBanner(skel.name .. player.id)
    if id then
      if Fk:currentRoom():getCardOwner(id) and Fk:currentRoom():getCardOwner(id).id == player.id then
        use.card:addSubcard(id)
      end
      Fk:currentRoom():setBanner(skel.name .. player.id, nil)
    end
  end,
  enabled_at_play = function(self, player)
    for _, s in ipairs({ "h", "e", "j" }) do
      if #player:getCardIds(s) == 1 then return true end
    end
    return false
  end,
  enabled_at_response = function(self, player, response)
    return not response and self:enabledAtPlay(player)
  end,
})


skel:addEffect(fk.BuryVictim, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill("lb__juju") and data.damage and data.damage.from and data.damage.from == player and
    target.rest == 0                                                                                                            --休整
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player.room:addPlayerMark(player, MarkEnum.SlashResidue)
    data.extra_data = data.extra_data or {}
    data.extra_data.skip_reward_punish = true
  end,
})

return skel
